
//需求：输入框为空的时候，不能提交
let text = document.querySelector('.mask-int input')
let pwd = document.querySelector('.mask-subint input')
let mbtn = document.querySelector('.mask-btn')
mbtn.addEventListener('click', function () {
    if (input.value === '') return
    if (pwd.value === '') return
})


//需求：判断手机和密码设置是否合法
let userMsg = document.querySelector('#userMsg')
let reg = /^(13[0-9]|14[01456879]|15[0-3,5-9]|16[2567]|17[0-8]|18[0-9]|19[0-3,5-9])\d{8}$/
text.addEventListener('blur', function () {
    let bool = reg.test(text.value)
    if (bool == true) {
        userMsg.textContent = ''
    } else {

        userMsg.textContent = '请输入正确的电话号码'
    }
})

//判断密码是否合法
let pwdMsg = document.querySelector('#pwdMsg')
let reg1 = /^\d{6}$/
pwd.addEventListener('blur', function () {
    let bool = reg1.test(pwd.value)
    if (bool == true) {

        pwdMsg.textContent = ''
    } else {

        pwdMsg.textContent = '请输入正确的密码'
    }
})
//需求：当内容大于1时，出现隐藏精灵图点击精灵图清空内容
let img1=document.querySelector('.mask-int img')
let img2=document.querySelector('.mask-subint img')
text.addEventListener('input',function(){
    if(text.value.length>0){
        img1.style.display='block'
    }else{
        img1.style.display='none'
    }
})
img1.addEventListener('click',function(){
    text.value=''
    img1.style.display='none'
})



pwd.addEventListener('input',function(){
    if(pwd.value.length>0){
        img2.style.display='block'
    }else{
        img2.style.display='none'
    }
})
img2.addEventListener('click',function(){
    pwd.value=''
    img2.style.display='none'
})

//点击提交时判断密码和电话框
mbtn.addEventListener('click',function(){
    if(!reg.test(text.value)){
        userMsg.textContent='用户名错误'
    }else if(!reg1.test(pwd.value)){
        pwdMsg.textContent='密码错误'
    }else{
        location.href='../page/首页.html'
    }
})

//点击扫码登陆时，。。。。
let dl3=document.querySelector('.mask-dl3')
let dl1=document.querySelector('.mask-dl1')
let zh=document.querySelector('.mask-zh')
let sm=document.querySelector('.mask-sm')
dl3.addEventListener('click',function(){
    dl3.style.borderBottom='#1271ef 2px solid'
    dl3.style.color='#1271ef'
    dl1.style.borderBottom='none'
    dl1.style.color='#6666'
    zh.style.display='none'
    sm.style.display='block'

})

dl1.addEventListener('click',function(){
    dl1.style.borderBottom='#1271ef 2px solid'
    dl1.style.color='#1271ef'
    dl3.style.borderBottom='none'
    dl3.style.color='#6666'
    zh.style.display='block'
    sm.style.display='none'
})

